<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WebSocket Chat</title>
    <style>
        body { 
            font-family: Arial, sans-serif; 
            margin: 0; 
            padding: 0;
            height: 100vh;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        #login { 
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            padding: 20px;
            border-radius: 15px;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
            text-align: center;
        }
        #login h2 {
            margin-top: 0;
            color: white;
        }
        #login input, #login button {
            padding: 10px;
            margin: 5px;
            border: none;
            border-radius: 5px;
        }
        #login button {
            background: #4CAF50;
            color: white;
            cursor: pointer;
        }
        #chat { 
            display: none;
            width: 100%;
            height: 100%;
            position: relative;
            padding: 20px;
            box-sizing: border-box;
        }
        #messages { 
            position: absolute;
            left: 20px;
            bottom: 80px;
            width: 250px;
            height: 150px;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 15px;
            overflow-y: scroll;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
        }
        #user-list { 
            position: absolute;
            left: 20px;
            top: 20px;
            width: 150px;
            height: 200px;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(10px);
            border-radius: 15px;
            padding: 15px;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
            overflow-y: auto;
        }
        #user-list ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        #user-list li {
            padding: 5px 0;
            color: white;
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }
        #user-list li:hover {
            background: rgba(255,255,255,0.1);
            cursor: pointer;
        }
        #user-list h3 {
            margin-top: 0;
            color: white;
        }
        #message-container {
            position: fixed;
            bottom: 20px;
            left: 0;
            right: 0;
            display: flex;
            justify-content: center;
            gap: 10px;
            padding: 0 20px;
        }
        #message {
            flex: 1;
            max-width: 70%;
            padding: 10px;
            border: none;
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.8);
        }
        #chat button {
            padding: 10px 20px;
            background: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        @media (max-width: 300px) {
            #messages, #user-list {
                width: 90%;
            }
            #user-list {
                height: 20%;
            }
        }
    </style>
</head>
<body>
    <div id="login">
        <h2>登录</h2>
        <input type="text" id="username" placeholder="输入用户名">
        <button onclick="login()">登录</button>
    </div>

    <div id="chat">

        <div id="message-container">
            <input type="text" id="message" placeholder="输入消息">
            <button onclick="sendMessage()">发送</button>
        </div>
        <div id="messages">
        </div>
        <div id="user-list">
            <h3>在线用户</h3>
            <ul id="users"></ul>
        </div>
    </div>

    <script src="./src/client.ts"></script>
</body>
</html>